#include <iostream>
#include<cstring>
#include<cmath>
using namespace std;
//建立在堆上
class Point{
public:
    static Point&  getinstall(){
       //避免重复
        if(!po){
            po =   new Point(1,2,"one");

        }return *po;
    }
    void gets(){
        for(int i=0;i<5;i++){
            cout<<_num[i]<<" "<<endl;
        }
        cout<<"x:"<<_x<<"y:"<<_y<<"name:"<<_name<<endl;
    }
    //必须手动销毁 因为是自己手动创建了类
    static void destroy(){
        if(po){
            delete po;
            po = nullptr;
        }
        cout<<"delete:"<<endl;
    }
private:
    Point(int x,int y,const char*name)
        :_x(x)
        ,_y(y)
        ,_num(new int[7]())
        ,_name(new char[strlen(name)+1]())
        {
            for(int i=0;i<5;i++){
                _num[i] = i;
            }
            strcpy(_name,name);
            cout<<"Point"<<endl;
             
         }
    ~Point(){
        if(_name){
            delete [] _name;
            _name = nullptr;
        }
        if(_num){
            delete [] _num;
            _num = nullptr;
        }
        cout<<"~Point"<<endl;
    }
    Point (const Point&)=delete;
    Point &operator=(const Point&)=delete;
    int _x;
    int _y;
    int *_num;
    char *_name;
    static Point *po;
};
//定义格式需要注意
Point* Point::po = nullptr;

int main()
{
    Point::getinstall().gets();
    Point::destroy();
    Point::getinstall().gets();
    Point::destroy();
    return 0;
}

